package fr.rhoc.android;

import fr.rhoc.android.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class Main extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		ImageButton lnkActivityLundi = (ImageButton) findViewById(R.id.lnk_activity_lundi);
		lnkActivityLundi.setOnClickListener(new OnClickListener() {

			public void onClick(View arg0) {
				Intent intent = new Intent(Main.this, ViewKikivient.class);
				Bundle bunble = new Bundle();
				bunble.putInt(ViewKikivient.DAY, 1);
				intent.putExtras(bunble);
				startActivity(intent);
			}
		});
		
		ImageButton lnkActivityMardi = (ImageButton) findViewById(R.id.lnk_activity_mardi);
		lnkActivityMardi.setOnClickListener(new OnClickListener() {

			public void onClick(View arg0) {
				Intent intent = new Intent(Main.this, ViewKikivient.class);
				Bundle bunble = new Bundle();
				bunble.putInt(ViewKikivient.DAY, 2);
				intent.putExtras(bunble);
				startActivity(intent);
			}
		});

		ImageButton lnkActivitySamedi = (ImageButton) findViewById(R.id.lnk_activity_samedi);
		lnkActivitySamedi.setOnClickListener(new OnClickListener() {

			public void onClick(View arg0) {
				Intent intent = new Intent(Main.this, ViewKikivient.class);
				Bundle bunble = new Bundle();
				bunble.putInt(ViewKikivient.DAY, 6);
				intent.putExtras(bunble);
				startActivity(intent);
			}
		});

		
		ImageButton lnkSendMail = (ImageButton) findViewById(R.id.lnk_activity_mail);
		lnkSendMail.setOnClickListener(new OnClickListener() {

			public void onClick(View arg0) {
				Intent intent = new Intent(Main.this, SendMail.class);
				startActivity(intent);
			}
		});

		
//		TextView lnkWebMardi = (TextView) findViewById(R.id.lnk_web_mardi);
//		TextView lnkWebSamedi = (TextView) findViewById(R.id.lnk_web_samedi);
//
//		lnkWebMardi.setOnClickListener(new OnClickListener() {
//
//			public void onClick(View arg0) {
//				Uri uri = Uri.parse("http://www.rhoc.fr/kikivientmardi/");
//				Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//				startActivity(intent);
//			}
//		});
//
//		lnkWebSamedi.setOnClickListener(new OnClickListener() {
//
//			public void onClick(View arg0) {
//				Uri uri = Uri
//						.parse("http://www.rhoc.fr/kikivientsamedi/indexnarrowscreen.php");
//				Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//				startActivity(intent);
//			}
//		});

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// call the base class to include system menus
		super.onCreateOptionsMenu(menu);
		MenuItem itemParameters = menu.add(0 // Group
				, 1 // item id
				, 0 // order
				, R.string.parameters); // title
		
		
		itemParameters.setIcon(android.R.drawable.ic_menu_preferences);
		
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()) {
		case 1:
			Intent intent = new Intent(Main.this, UpdateParameters.class);
			startActivity(intent);
			return true;
		}

		// for the rest
		return super.onOptionsItemSelected(item);
	}

}